<template>
	<view class="all">
		<view class="status_bar">
			<!-- 这里是状态栏 -->
		</view>
		<view class="fidexs">
			<view class="all_title">
				<view class="groups" @click="tos">
					<u-icon name="arrow-left" :bold="true" color="rgba(46, 46, 46, .5)" size="20"></u-icon>
					<view class="mod">分类</view>
				</view>
				<u-icon name="home" color="rgba(46, 46, 46, .5)" @click="mesg" size="28"></u-icon>
			</view>
		</view>
		<view class="kind">
			<view class="kind_l">
				<view class="kind_nav" v-for="(item,index) in list" :class="index==num?'hide':''" :key="index"
					@click="act(index)">
					{{item.freeTypeName}}
				</view>
			</view>
			<view class="kind_r" v-for="(item,n) in list" :key="n" v-show="n==num">
				<view class="kind_r_cupe" v-for="(items,i) in item.categoryList" :key="i"
					@click="pop(items.categoryId)">
					<image :src="items.categoryCover"></image>
					<view class="books">{{items.categoryName}}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: '',
				num: 0
			}
		},
		onLoad() {
			uni.$http.get("https://m.taoyuewenhua.com/ajax/book_mall/categories").then(res => {
				this.list = res.data.data.freeTypeList
				console.log(this.list)
			}).catch(err => {
				console.log(err)
			})
		},
		methods: {
			tos() {
				uni.navigateTo({
					url: "/pages/message/message"
				})
			},
			mesg() {
				uni.navigateBack({
					url: '/pages/message/message'
				})
			},
			act(i) {
				console.log(i, 11)
				this.num = i
			},
			pop(id) {
				console.log(id, 999454546)
				uni.navigateTo({
					url: "/pages/particulars/particulars?categoryId=" + id
				})
			},
		},
	}
</script>

<style lang="scss">
	.all {
		background: #eee;
		width: 100%;
	}

	.fidexs {
		position: fixed;
		top: var(--status-bar-height);
		right: 0;
		left: 0;
		background: #fff;
		z-index: 11;
		border-bottom: 2rpx solid #eee;
	}

	.all_title {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 0 30rpx;
		height: 80rpx;
		border-bottom: 2rpx solid #ededed;
		background-color: #fff;

		.groups {
			display: flex;
			align-items: flex-end;

			.mod {
				margin-left: 20rpx;
			}
		}
	}

	.kind {
		display: flex;
		flex-wrap: wrap;
		justify-content: space-between;
		margin-top: 80rpx;

		.kind_l {
			width: 150rpx;
			height: 100vh;

			.kind_nav {
				text-align: center;
				height: 120rpx;
				line-height: 120rpx;
			}
		}

		.kind_r {
			width: 73%;
			padding-left: 52rpx;
			background: #fff;

			.kind_r_cupe {
				width: 50%;
				padding-top: 40rpx;
				float: left;
				display: flex;
				align-items: center;

				image {
					width: 84rpx;
					height: 120rpx;
				}

				.books {
					padding-left: 15rpx;
				}
			}
		}
	}

	.hide {
		background-color: #fff;
		border-left: 6rpx solid #ffa600;
		box-sizing: border-box;
		color: #ffa600;
	}

	.status_bar {
		height: var(--status-bar-height);
		width: 100%;
	}
</style>
